package com.dxysun.design.memento;

public class Main
{
	public static void main(String[] args)
	{
		Caretaker caretaker = new Caretaker();
		System.out.println("设置状态");
		Originator originator = new Originator();
		originator.setState("a");
		System.out.println(originator.getState());
		caretaker.storeMemento(originator.createMemento());
		originator.setState("b");
		System.out.println(originator.getState());
		caretaker.storeMemento(originator.createMemento());
		System.out.println("恢复状态");
		originator.restoreMemento(caretaker.getMemento());
		System.out.println(originator.getState());
		originator.restoreMemento(caretaker.getMemento());
		System.out.println(originator.getState());
	}
}
